/**
 * 
 */
package com.xbang.attendance.web.action.warehouse.warn;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.xbang.attendance.entity.product.Product;
import com.xbang.attendance.entity.product.ProductCategory;
import com.xbang.attendance.entity.stock.InventoryWarningRecord;
import com.xbang.attendance.entity.system.Warehouse;
import com.xbang.attendance.service.InventoryService;
import com.demo2do.lighturl.annotation.Action;
import com.xbang.core.page.Result;
import com.xbang.core.struts.support.SearchActionSupport;

/**
 * @author dev.zhang
 * 
 */
public class Search extends SearchActionSupport {

	private static final long serialVersionUID = 8792923545485296635L;

	private static final Log logger = LogFactory.getLog(Search.class);

	@Autowired
	private InventoryService inventoryService;
	
	private List<Warehouse> chooseWarehouse = new ArrayList<Warehouse>();

	private List<Product> chooseProduct = new ArrayList<Product>();
	
	private List<ProductCategory> chooseProductCategories = new ArrayList<ProductCategory>();
	
	private List<InventoryWarningRecord> inventoryWarningRecords = new ArrayList<InventoryWarningRecord>();

	public String execute() throws Exception {
		chooseProduct = inventoryService.getObjects(Product.class);
		chooseWarehouse = inventoryService.getObjects(Warehouse.class);
		chooseProductCategories = inventoryService.getObjects(ProductCategory.class);
		return "search";
	}
	
	
	
	@Action("/warehouse/warn/search/do")
	public String doSearch() throws Exception {
		String hqlSentence = "FROM InventoryWarningRecord inventorywarningrecord WHERE 1 = 1 ";
		Result result = inventoryService.searchByPage(hqlSentence, searchComponent, page);
		inventoryWarningRecords = result.getItems();
		page = result.getPage();
		
		return "index";
	}

	@Override
	public void resetCustomerSearchCriteria() {
		// TODO Auto-generated method stub

	}

	public InventoryService getInventoryService() {
		return inventoryService;
	}

	public void setInventoryService(InventoryService inventoryService) {
		this.inventoryService = inventoryService;
	}

	public List<Warehouse> getChooseWarehouse() {
		return chooseWarehouse;
	}

	public void setChooseWarehouse(List<Warehouse> chooseWarehouse) {
		this.chooseWarehouse = chooseWarehouse;
	}

	public List<Product> getChooseProduct() {
		return chooseProduct;
	}

	public void setChooseProduct(List<Product> chooseProduct) {
		this.chooseProduct = chooseProduct;
	}

	public List<InventoryWarningRecord> getInventoryWarningRecords() {
		return inventoryWarningRecords;
	}

	public void setInventoryWarningRecords(
			List<InventoryWarningRecord> inventoryWarningRecords) {
		this.inventoryWarningRecords = inventoryWarningRecords;
	}



	public List<ProductCategory> getChooseProductCategories() {
		return chooseProductCategories;
	}



	public void setChooseProductCategories(
			List<ProductCategory> chooseProductCategories) {
		this.chooseProductCategories = chooseProductCategories;
	}

	
}
